<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<script type="text/javascript">
<!--

//-->
</script>
<style>
<!--
 	.btn_newsadd{
 		margin-left:50px; 
 	}
-->
</style>
<link href="css/style.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="<%=path %>/css/bootstrap.min.css" />
<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=path %>/js/resources/common.js"></script>
<%-- ueditor js --%> 
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/lang/zh-cn/zh-cn.js"></script>

    <jsp:include page="common.jsp"></jsp:include>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li>系统设置</li>
    <li><span id="lujing">公司简介</span></li> 
    <button class="btn btn-success pull-right" id="start">开始编辑</button> 
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>摘要内容</span></div>
    
    <ul class="forminfo">
    <li>
    	<textarea name="summary" id="summary" type="text" class="" style="width:90%;height:200px;"></textarea>
    </li>
    <div class="formtitle"><span>详细内容</span></div>
    <li>
    	<textarea name="description" id="description" type="text" class="" style="width:90%;height:600px;"></textarea>
    </li>
    
    
    <li>
    	<input name="" id="news_save" type="button" class="btn btn-primary btn_newsadd" style="margin-left:40%;" value="确认保存"/>
    </li>
    </ul>
    
    
    
    </div>
    
 <script type="text/javascript" >
 
	 var path='<%=basePath%>';
	 var uesummary = UE.getEditor('summary',{
		 imageUrlPrefix:path+'/'
	 });
	 var uedesc = UE.getEditor('description',{
		 imageUrlPrefix:path+'/'
	 });
	 
 $(function(){
	 $.post(path+"introduceAction_details.action",{
		 uuid:1
	 },function(res){
		 res=eval('('+res+')');
		 if(res.rescode=='100'){
			 uedesc.ready( function () {
				 uedesc.setContent(res.data.description);
			 });
			 
			 uesummary.ready( function () {
				 uesummary.setContent(res.data.summary);
			 });
		 }
	 });
	 stopEdit();
 });
 
 $("#start").bind("click",function(){
	 startEdit();
 });
 
 $("#news_save").unbind("click").bind("click",function(){
	 
	 if(validField()){
		 $.post(path+"introduceAction_update.action",{
			 uuid:1,
			 summary:uesummary.getContent(),
			 description:uedesc.getContent()
		 },function(res){
			 res=eval('('+res+')');
			 if(res.rescode=='100'){
				 alert(res.msg);
				 stopEdit();
			 }else{
				 alert(res.msg);
			 }
		 });
	 }
 });
 
 function validField(){
	 var v=uesummary.getContent();
	 if(!v){
		 showWarnMsg("摘要不能为空");
		 return false;
	 }
	 if(v.length<20 ){
		 showWarnMsg("摘要不能少于20个字符");
		 return false;
	 }
	 var c=uedesc.getContent();
	 if(!c){
		 showWarnMsg("详细内容不能为空");
		 return false;
	 }
	 if(c.length<40 ){
		 showWarnMsg("详细内容不能少于40个字符");
		 return false;
	 }
	 return true;
 }
 /*开始编辑*/
 function startEdit(){
	 uedesc.setEnabled();
	 uesummary.setEnabled();
	 $('#news_save').attr("disabled",false);
 }
 /*停止编辑*/
 function stopEdit(){
	 
	 uedesc.addListener("ready", function () {
		 uedesc.setDisabled();
	 });
	 
	 uesummary.addListener("ready", function () {
		 uesummary.setDisabled();
	 });
	 
	 
	 $("#news_save").attr("disabled",true);
	 
 }
 
 </script>